﻿var toolwords = "";
for (var i = 0; i < 20; i++) {
    b = Math.floor(Math.random() * 30 + 1);
    keysword = words[b];
    if (i == 0) {
        toolwords += "<li style=\"margin-top:-28px\">" + keysword + "</li>";
    } else {
        toolwords += "<li>" + keysword + "</li>";
    }

}

function showSetting(id) {
    var obj = $("#" + id);
    var offset = obj.offset();
    if (id == "setting") {
        $(document.body).append("<img src='/Content/images/set2.jpg' id=\"set2\" style=\"position:fixed;left:" + offset.left + "px;bottom:28px;\"/>");
    }
    if (id == "close") {
        $(document.body).append("<img src='/Content/images/close.jpg' id=\"set2\" style=\"position:fixed;left:" + offset.left + "px;bottom:28px;\"/>");
    }
    if (id == "open") {
        $(document.body).append("<img src='/Content/images/open.png' id=\"set2\" style=\"position:fixed;left:" + offset.left + "px;bottom:28px;\"/>");
    }
}
function hiddenSetting(id) {
    var obj = $("#set2");
    obj.remove();
}
function showorhiddendiv(id) {
    var obj = $("#" + id);
    var offset = obj.offset();
    if ($("#playdiv").length > 0) {
        $("#playdiv").remove();
    } else {
        $(document.body).append("<div id=\"playdiv\" style=\"border: 1px solid #252525;background-color:#ffffff;width:200px;position:fixed;left:" + (offset.left - 150) + "px;bottom:28px;\"><div style=\"background-color:#d1e5f7;color:#1d3a55; padding-left:10px;\"><b>设置</b></div><div style=\"padding-left:10px;\"><input type=\"radio\" name=\"usertype\" onclick=\"javascript:window.location='/OperatorRealtimeTransaction'\"/>我是短线交易者</div><div style=\"padding-left:10px;\"><input type=\"radio\" name=\"usertype\" onclick=\"javascript:window.location='/ChangXianRi'\"/>我是长线交易者</div></div>");
    }
}
function closediv(id) {
    var obj = $("#floatdiv");
    if (obj.length > 0) {
        //关闭
        obj.remove();
        hiddenSetting(1);
        $("#playdiv").remove();
        $(document.body).append(openString);
    } else {
        //开启
        var obj = $("#floatdiv2");
        obj.remove();
        hiddenSetting(1);
        $("#playdiv").remove();
        $(document.body).append(divString);
    }
}
var divString = "<div style=\"width: 90%; background-image: url(/Content/images/tab.jpg); position: fixed;" +
                "border: 1px solid #858570; bottom: 0px; left: 5%;\" align=\"center\" id=\"floatdiv\"><span></span>" +
                "<span style=\"float: right; background-image: url(/Content/images/split.jpg);background-repeat: no-repeat;\">" +
                "<span style=\"padding-left: 10px; padding-right: 10px;cursor: pointer;\" onmouseover=\"showSetting(this.id)\" " +
                "id=\"close\" onmouseout=\"hiddenSetting(this.id)\" onclick=\"closediv(this.id)\">关闭</span></span>" +
                "<span style=\"float: right; background-image: url(/Content/images/split.jpg); background-repeat: no-repeat;\">" +
                "<span style=\"padding-left: 10px; padding-right: 10px; cursor: pointer;height:28px;line-height:28px;\"><img style=\"padding-top:0px;padding-top:3px !important;>padding-top:0px !important;\" src=\"/Content/images/set.jpg\" " +
                "title=\"设置\" alt=\"设置\" onmouseover=\"showSetting(this.id)\"  id=\"setting\" onmouseout=\"hiddenSetting(this.id)\"" +
                " onclick=\"showorhiddendiv(this.id)\" /></span></span>" +
                "<div style=\" padding-right: 10px; cursor: pointer;float: left; padding-left:10px; text-align:left;width:80%;\" id=\"scrollDiv\"><ul>" + toolwords + "</ul></div></div>";

var openString = "<div style=\"background-image: url(/Content/images/tab.jpg); position: fixed;" +
                "border: 1px solid #858570; bottom: 0px; left: 92%;\" align=\"center\" id=\"floatdiv2\"><span></span>" +
                "<span style=\"padding-left: 10px; padding-right: 10px;cursor: pointer;\" onmouseover=\"showSetting(this.id)\" " +
                "id=\"open\" onmouseout=\"hiddenSetting(this.id)\" onclick=\"closediv(this.id)\">打开</span>" + "</div>";

function AutoScroll(obj) {
    $(obj).find("ul:first").animate({
        marginTop: "-28px"
    }, 500, function () {
        $(this).css({ marginTop: "0px" }).find("li:first").appendTo(this);
    });
}
$(document).ready(function () {
    $(document.body).append(divString);
    setInterval('AutoScroll("#scrollDiv")', 5000);
});


